local lianxi = fk.CreateSkill{
  name = "hanqing__lianxi",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["hanqing__lianxi"] = "连袭",
  [":hanqing__lianxi"] = "锁定技，当你使用牌时，若中央区含有相同花色的牌，则此牌不可被响应；若你手牌数不大于中央区牌数，则你摸一张牌。"..
  "若两项均满足，则此牌伤害+1；否则，你弃置一张牌。",

  ["$hanqing__lianxi1"] = "先登者当赐簪袅！",
  ["$hanqing__lianxi2"] = "后退者头悬辕门！",
}

lianxi:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(lianxi.name) then
      local choices = {}
      if table.find(player.room:getBanner("@$CenterArea"), function (id)
        return data.card:compareSuitWith(Fk:getCardById(id))
      end) then
        table.insert(choices, 1)
      end
      if player:getHandcardNum() <= #player.room:getBanner("@$CenterArea") then
        table.insert(choices, 2)
      end
      event:setCostData(self, {choices = choices})
      if #choices == 0 then
        return not player:isNude()
      elseif table.contains(choices, 2) then
        return true
      else
        return not player:isNude() or (data.card.trueName == "slash" or data.card:isCommonTrick())
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = event:getCostData(self).choices
    if table.contains(choices, 1) then
      data.disresponsiveList = table.simpleClone(room.players)
    end
    if table.contains(choices, 2) then
      player:drawCards(1, lianxi.name)
    end
    if #choices == 2 then
      data.additionalDamage = (data.additionalDamage or 0) + 1
    elseif not player.dead and not player:isNude() then
      room:askToDiscard(player, {
        min_num = 1,
        max_num = 1,
        include_equip = true,
        skill_name = lianxi.name,
        cancelable = false,
      })
    end
  end,
})

lianxi:addAcquireEffect(function (self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

return lianxi
